#include "my_global.h"
#include "my_sys.h"
#include "handler.h"
#include "samtools/sam.h"
/*BAM Fields */
#define QNAME QNAME
#define FLAG  FLAG
#define RNAME RNAME
#define POS	  POS
#define MAPQ  MAPQ
#define CIGAR CIGAR
#define MRNM  MRNM
#define MPOS  MPOS
#define ISIZE ISIZE
#define SEQ   SEQ
#define QUAL  QUAL


class Bam_data
{
public:
   Bam_data(void);
  ~Bam_data(void);
  int open_bam(const char *path);
  int close_bam();
  int read_bam_alignment(TABLE *table, int position, unsigned char *buf);

  int reset_bam();
  int get_position();
  int64_t get_block_address();
  int get_block_offset();
  int get_block_length();
  int reset_row_count();
  int set_position(int64_t block, int offset);
  long get_row_count();

  /*long long cur_position();*/
private:
  	bamFile bam_file;
  	bam_header_t *bam_header;
  	int bam_position;
  	int64_t block_address;
  	int block_offset;
  	int bloc_length;
  	long row_count;
  	bam1_t* b;
};
